import service from '@/utils/request'

// 执行器里列表
export const actuatorDataList = () => {
	return service.get('/data-development/jobExecute/list-all')
}

// 执行器详情接口
export const actuatorApi = (id: number) => {
	return service.get(`/data-development/jobExecute/${id}`)
}

// 执行器编辑/新增
export const actuatorPostSubmit = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/data-development/jobExecute', dataForm)
	} else {
		return service.post('/data-development/jobExecute', dataForm)
	}
}

// 执行器 手动录入 ip测试
export const actuatorIpTest = (dataForm: any) => {
	return service.post('/data-development/jobExecute/job_test', dataForm)
}

// 执行指令测试
export const actuatorCmdTest = (dataForm: any) => {
	return service.post('/data-development/jobExecute/shell-test', dataForm)
}

// 调度组 编辑/新增
export const schedulerGroupPostSubmit = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/data-development/ScheduleGroup', dataForm)
	} else {
		return service.post('/data-development/ScheduleGroup', dataForm)
	}
}

// 调度组详情
export const schedulerApi = (id: number) => {
	return service.get(`/data-development/ScheduleGroup/${id}`)
}

// 作业组件
// 构建
export const buildDataxJson = (dataForm: any) => {
	return service.post('/data-development/task/build-datax-json', dataForm)
}
// 保存
export const savedataxjson = (dataForm: any) => {
	return service.post('/data-development/task/save-datax-json', dataForm)
}

// 数据接入
// 获取表字段
export const getTableColumns = (id: any, tableName: any) => {
	return service.get(`/data-integrate/database/${id}/${tableName}/columns`)
}

// sql获取字段
export const getSqlColumns = (id: any, sql: any) => {
	return service.post(`/data-integrate/database/getColumnsByQuerySql`, { datasourceId: id, querySql: sql })
}

// 构建
export const buildJson = (dataForm: any) => {
	return service.post('/data-integrate/datax/buildJson', dataForm)
}

// 保存
export const saveDataX = (dataForm: any) => {
	if (dataForm.id) {
		return service.post('/data-integrate/access/dataX/update', dataForm)
	} else {
		return service.post('/data-integrate/access/dataX/save', dataForm)
	}
}

// 执行datax作业
export const executeDataX = (id: any, time: any) => {
	return service.get('/data-development/task/execute-datax/' + id + '?time=' + time)
}

export const getDataXJobLog = (id: any, time: any, requestId: any) => {
	return service.get('/data-development/task/datax-log/' + id + '?requestId=' + requestId)
}

// datax作业 停止
export const stopDataXJob = (id: any) => {
    return service.get('/data-development/task/sto_idtl?requestId=' + id)
}

// 数据概览接口
export const getStatistics = (startTime: any, endTime: any) => {
	return service.get('data-development/statistics/index?startTime=' + startTime + '&endTime=' + endTime)
}
export const getStatisticsTime = (startTime: any, endTime: any, id: any) => {
	return service.get('data-development/statistics/time?startTime=' + startTime + '&endTime=' + endTime + '&id=' + (id ? id : ''))
}
export const getStatisticsRatio = (id: any) => {
	return service.get('data-development/statistics/ratio?id=' + id)
}
export const getStatisticsStatus = (id: any) => {
	return service.get('data-development/statistics/status?id=' + id)
}
export const getStatisticsChose = () => {
	return service.get('data-development/statistics/chose')
}
export const getStatisticsList = (startTime: any, endTime: any, id: any) => {
	return service.get('data-development/statistics/list?startTime=' + startTime + '&endTime=' + endTime + '&id=' + (id ? id : ''))
}
export const getStatisticsExecution = (startTime: any, endTime: any, id: any) => {
	return service.get('data-development/statistics/execution?startTime=' + startTime + '&endTime=' + endTime + '&id=' + (id ? id : ''))
}
